package trunk.gui;

import trunk.res.R;

import javax.swing.*;
import java.awt.*;

/**
 * Simulator will contain $SimulatePanel$, $InstructionPanel$ and $ParameterPanel$
 * Created by IntelliJ IDEA.
 * User: yipeipei
 * Date: 11/28/11
 * Time: 10:55 PM
 * To change this template use File | Settings | File Templates.
 */
public class Simulator extends JFrame {
    SimulatePanel simulatePanel;
    InstructionPanel instructionPanel;
    ParameterPanel parameterPanel;
    MicrocodePanel microcodePanel;
 
    MicrocodePanel outputInstructionPanel;
    public Simulator() {
        super(R.string.APP_NAME);   //set app name which to be displayed in title bar

        initialize();

        this.setVisible(true);
    }

        /**
     * initializeAuxiliary the simulate frame
     */
    public void initialize() {
        this.setIconImage(R.drawable.LOGO.getImage());  //set a logo in the title bar

        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setSize(R.attribute.FRAME_WIDTH, R.attribute.FRAME_HEIGHT);
        this.setResizable(false);   //for some layout reason, better not to resize the frame
        this.setLayout(null);   //use null layout with setBounds() to exactly place a component

        this.setName("Simulator");  //set name for this frame

        //add all the panels into simulate frame
        this.simulatePanel = new SimulatePanel();
        this.instructionPanel = new InstructionPanel();
        this.parameterPanel = new ParameterPanel();
        this.microcodePanel = new MicrocodePanel();
        this.outputInstructionPanel = new MicrocodePanel(
                                           R.attribute.SIM_PANEL_WIDTH,
                                           R.attribute.INSTRUCTION_PANEL_HEIGHT + R.attribute.PARAMETER_PANEL_HEIGHT,
                                           R.attribute.MICROCODE_PANEL_WIDTH,
                                           50);

        this.add(simulatePanel);
        this.add(new StatusPanel());
        this.add(instructionPanel);
        this.add(parameterPanel);
        this.add(microcodePanel);
        this.add(outputInstructionPanel);
    }

    public SimulatePanel getSimulatePanel() {
        return simulatePanel;
    }

    public InstructionPanel getInstructionPanel() {
        return instructionPanel;
    }

    public ParameterPanel getParameterPanel() {
        return parameterPanel;
    }

    public MicrocodePanel getMicrocodePanel() {
        return microcodePanel;
    }
    public MicrocodePanel getOutputinstructionPanel() {
        return outputInstructionPanel;
    }
}
